home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000178_icon-group-sender _Thu Jun 16 21:43:30 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
2KB
Received: by cheltenham.cs.arizona.edu; Fri, 17 Jun 1994 08:06:39 MST
Date: Thu, 16 Jun 1994 21:43:30 MST
From: "Clinton L. Jeffery" <cjeffery>
Message-Id: <199406170443.AA15757@cheltenham.cs.arizona.edu>
To: eric@star-semi.com
Cc: icon-group@cs.arizona.edu
In-Reply-To: Eric Armstrong's message of Thu, 16 Jun 94 12:27:04 PDT <9406161927.AA07961@star-semi.com>
Subject: Re: booleans, enumerations, globals
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
[Eric writes:]
I'm wondering what idioms you guys use to:
a. Do a simple boolean test, like
if a=true -or- if a=false
As in LISP, use of the null value is common for this sort of value.
if \a then ... # if a is not null <==> if a is true
if /a then ... # if a is null <==> if a is false
Note that most Icon-ers avoid "boolean variables" entirely when they can.
b. Create something like a Pascal enumeration type
Days of the week, for example. I create a list of strings:
["Mon", "Tue", ...] but then I index it by a number (weekday[2]).
How would it be possible to index it as weekday[Tue]?
Two options come to mind, both dependent upon recent additions to Icon.
I am not sure if they are both in 8.10; I think at least option #1 is.
Option #1 is to $define each value in your enumeration:
$define Mon 1
$define Tue 2
Option #2 is to define a record type
record week(Mon,Tue,Wed,Thu,Fri,Sat,Sun)
then if weekday := week() you can say weekday.Mon or weekday["Mon"]
c. initialize globals
There is no help for this and it is a deficiency in the language.
How much is fixing it worth? :-)
Clint Jeffery, jeffery@ringer.cs.utsa.edu, cjeffery@cs.arizona.edu
U. of Texas at San Antonio